#include <Magick++.h>

int main( int in_argc, char** in_argv )
{

  Magick::InitializeMagick(*in_argv);

  Magick::Image image;

  try 
  {
    image.read( "/home/cloud/flower.jpg" );

    //image.enhance();
    //image.equalize();
    //image.normalize();
    image.gaussianBlur(20,0.5);

    // Write the image to a file
    image.write( "/home/cloud/flower2.jpg" );
  }
  catch( Magick::Exception &error_ )
  {
    printf(error_.what());
    printf("\n");
    return 1;
  } 

  return 0;
}

QImage QImageFromIMImage(Magick::Image &image)
{

   QImage qimage = QImage( image.columns(), image.rows(), QImage::Format_RGB32);
   Magick::ColorRGB rgb;

   const int qheight = qimage.height();
   const int qwidth  = qimage.width();
   
   for( int row = 0; row < qheight; ++row ) 
   {
      const Magick::PixelPacket* const  pixels = image.getConstPixels( 0, row, qwidth, 1 );
      for( int col = 0; col < qwidth; ++col ) 
      {
         rgb = *( pixels + col );
         const QRgb qrgb = qRgb( static_cast<int>( 255 * rgb.red  () ),
                                 static_cast<int>( 255 * rgb.green() ),
                                 static_cast<int>( 255 * rgb.blue () ) );
         qimage.setPixel( col, row, qrgb );
      }
   }
  
   return qimage;
}

